package cn.itsource.org.service.impl;

import cn.itsource.base.query.BaseQuery;
import cn.itsource.org.domain.Department;
import cn.itsource.org.domain.Dictionary;
import cn.itsource.org.mapper.DictionaryMapper;
import cn.itsource.org.query.DictionaryQuery;
import cn.itsource.org.service.IDictionaryService;
import cn.itsource.utli.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
public class DictionaryServiceImpl implements IDictionaryService {
    @Autowired
    private DictionaryMapper dictionaryMapper;


    @Override
    @Transactional
    public void save(Dictionary dictionary) {
        dictionaryMapper.save(dictionary);
    }

    @Override
    @Transactional
    public void update(Dictionary dictionary) {
        dictionaryMapper.update(dictionary);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        dictionaryMapper.delete(id);
    }

    @Override
    public Dictionary queryById(Long id) {
        return dictionaryMapper.queryById(id);
    }

    @Override
    public List<Dictionary> queryAll() {
        return dictionaryMapper.queryAll();
    }

    @Override
    public PageInfo<Dictionary> queryPage(DictionaryQuery query) {
        Long count = dictionaryMapper.count(query);
        List<Dictionary> list = dictionaryMapper.queryDate(query);
        return new PageInfo<>(count,list);
    }


    @Override
    public List<Dictionary> getDeptTree() {
        return dictionaryMapper.getDeptTree();
    }
}
